<template>
	<view>
		<u-navbar :border-bottom="false" title="问题反馈" back-icon-color="#ffffff" :background="{background:'#2149c3'}" title-color="#ffffff"></u-navbar>
		<view class="feed_box">
			<view class="feed_nr_bg">
				<view class="h1">问题反馈</view>
				<view class="h2">产品建议 <text>（出现问题）</text></view>
				<view class="textarea_view">
					<u-input v-model="textareaValue" type="textarea" :border="false" :height="true" :auto-height="true" :clearable="false" height="380" placeholder="感谢您对产品提出的宝贵问题，我们会尽快优化产品，提升用户体验"/>
				</view>
				<view class="btn1">
					<u-button size="default" type="primary" :ripple="true" ripple-bg-color="#2979ff" @click="savefeedback()">提交</u-button>
				</view>
			</view>
			<u-toast ref="uToast" />
		</view>
	</view>
</template>

<script>
	var maxNum = 3, _self;
	import {
		mapState,
		mapMutations
	} from 'vuex';	
	export default {
		computed: {
			...mapState(['userInfo', 'hasLogin', 'loginProvider', 'openid'])
		},
	    data() {
	        return {
				userarr:[],
				textareaValue:''
	        }
	    },
		onShow() {
			this.getMember('');
		},
		onLoad(){
			_self = this;
			this.getMember('card');
		},
	    methods:{
			...mapMutations(['login', 'logout', 'setOpenid', 'setProvider']),
			getMember : function(t){
			    uni.request({
			    	url: this.serverUrl + 'app/getMember',
			    	header: {
			    		"content-type": "application/x-www-form-urlencoded; charset=UTF-8"
			    	},
			    	method: 'POST',
			    	data: {
						id: this.userInfo.id,
			    	},
			    	success: (r) => {
			    		if (r.data.code==0) {
							if(t==''){
								this.userarr = r.data.data;
								console.log(this.userarr)
							}else{
								
							}
						}else{
							console.log('111')
						}
					}
				})
			},
			savefeedback: function(){
				if(this.textareaValue == '' || this.textareaValue == null){
					console.log("意见反馈不能为空");
					this.$refs.uToast.show({
						title: '意见反馈不能为空',
						type: 'error'
					})
					return;
				}else if(this.userarr.realName == '' || this.userarr.realName == null || this.userarr.realName == undefined){
					this.userarr.realName = '暂未设置姓名'
				}
				uni.request({
					url: this.serverUrl + 'app/addFeedback',
					header: {
						"content-type": "application/x-www-form-urlencoded; charset=UTF-8"
					},
					method: 'POST',
					data: {
						memberId: this.userarr.id,
						realname:this.userarr.realName,
						telephone:this.userarr.telephone,
						content:this.textareaValue
					},
					success: (r) => {
						console.log(r,r.data.code)
						if (r.data.code==1) {
							this.$refs.uToast.show({
								title: '提交成功',
								type: 'success'
							})
							this.textareaValue = "";
						}else{
						}
					}
				})
			}
		}
	}
</script>

<style lang="less">
	page{
		background-color: #f0f0f0;
	}
	.feed_box{
		padding: 40rpx 20rpx;
	}
	.feed_nr_bg{
		background-color: #FFFFFF;
		padding: 20rpx 30rpx 80rpx 30rpx;
		border-radius: 10rpx;
		.h1{
			font-size: 42rpx;
			font-weight: bold;
			padding-bottom: 15rpx;
			letter-spacing: 3rpx;
			color: #333333;
		}
		.h2{
			font-size: 30rpx;
			color: #333333;
			padding-bottom: 15rpx;
			text{
				color: #999999;
			}
		}
		
		.textarea_view{
			height: 380rpx;
			background-color: #ffffff;
			border-radius: 10rpx;
			border: solid 1rpx #dcdcdc;
			padding: 20rpx;
		}
		.btn1{
			margin-top: 80rpx;
		}
	}
</style>
